package edu.ncsu.csc.ip.server;

import java.util.Date;

import edu.ncsu.csc.ip.common.serializer.Transfer;

/**
 * Class <code></code>
 * 
 * 
 * 
 * @author Moin Ayazifar <mayazif@ncsu.edu>
 * @author Steven Elliott <sdelliot@ncsu.edu>
 * 
 */

public class ClientBean {

	private String screenName;

	@Transfer
	private String hostname;

	@Transfer
	private String ipAddress;

	@Transfer
	private Integer rfcServerPort;

	@Transfer
	private Integer cookie;

	@Transfer
	private Boolean activeFlag;

	@Transfer
	private Integer ttl;

	@Transfer
	private Integer lastAccess;

	@Transfer
	private Date lastAccessDate;

	@Transfer
	private Integer activityCount;

	/**
	 * @return the ipAddress
	 */
	public String getIpAddress() {
		return ipAddress;
	}

	/**
	 * @param ipAddress
	 *            the ipAddress to set
	 */
	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	/**
	 * @return the rfcServerPort
	 */
	public Integer getRfcServerPort() {
		return rfcServerPort;
	}

	/**
	 * @param rfcServerPort
	 *            the rfcServerPort to set
	 */
	public void setRfcServerPort(Integer rfcServerPort) {
		this.rfcServerPort = rfcServerPort;
	}

	/**
	 * @return the screenName
	 */
	public String getScreenName() {
		return screenName;
	}

	/**
	 * @param screenName
	 *            the screenName to set
	 */
	public void setScreenName(String screenName) {
		this.screenName = screenName;
	}

	/**
	 * @return the hostname
	 */
	public String getHostname() {
		return hostname;
	}

	/**
	 * @param hostname
	 *            the hostname to set
	 */
	public void setHostname(String hostname) {
		this.hostname = hostname;
	}

	/**
	 * @return the cookie
	 */
	public Integer getCookie() {
		return cookie;
	}

	/**
	 * @param cookie
	 *            the cookie to set
	 */
	public void setCookie(Integer cookie) {
		this.cookie = cookie;
	}

	/**
	 * @return the activeFlag
	 */
	public Boolean getActiveFlag() {
		return activeFlag;
	}

	/**
	 * @param activeFlag
	 *            the activeFlag to set
	 */
	public void setActiveFlag(Boolean activeFlag) {
		this.activeFlag = activeFlag;
	}

	/**
	 * @return the ttl
	 */
	public Integer getTtl() {
		return ttl;
	}

	/**
	 * @param ttl
	 *            the ttl to set
	 */
	public void setTtl(Integer ttl) {
		this.ttl = ttl;
	}

	/**
	 * @return the lastAccess
	 */
	public Integer getLastAccess() {
		return lastAccess;
	}

	/**
	 * @param lastAccess
	 *            the lastAccess to set
	 */
	public void setLastAccess(Integer lastAccess) {
		this.lastAccess = lastAccess;
	}

	/**
	 * @return the lastAccessDate
	 */
	public Date getLastAccessDate() {
		return lastAccessDate;
	}

	/**
	 * @param lastAccessDate
	 *            the lastAccessDate to set
	 */
	public void setLastAccessDate(Date lastAccessDate) {
		this.lastAccessDate = lastAccessDate;
	}

	/**
	 * @return the activityCount
	 */
	public Integer getActivityCount() {
		return activityCount;
	}

	/**
	 * @param activityCount
	 *            the activityCount to set
	 */
	public void setActivityCount(Integer activityCount) {
		this.activityCount = activityCount;
	}

	public void increaseActivityCount() {
		this.activityCount++;
	}

	@Override
	public boolean equals(Object clientBean) {
		if (clientBean == null)
			return false;
		if (clientBean instanceof ClientBean
				&& ((ClientBean) clientBean).getIpAddress().equals(getIpAddress())
				&& ((ClientBean) clientBean).getRfcServerPort().intValue() == getRfcServerPort().intValue())
			return true;
		return false;

	}

	@Override
	public int hashCode() {
		int hash = 1;
		hash = hash * 17 + getIpAddress().hashCode();
		hash = hash * 31 + getRfcServerPort().hashCode();
		return hash;
	}
	
	
	

	
}
